<?php


namespace App\Admin\Extensions;


use Encore\Admin\Form\Field;

class MarkDown extends Field
{
    protected $view = 'admin::form.editor';

    protected static $css = [
        '/plugins/markdown/dist/simplemde.min.css',
    ];

    protected static $js = [
        '/plugins/markdown/dist/simplemde.min.js',
    ];

    public function render()
    {
        // 兼容模型关联
        $column = str_replace('.', '_', $this->column);
        $this->script = <<<EOT
  new SimpleMDE({
               autofocus: true,
                autosave: {
                    enabled: true,
                    delay: 5000
                },
                spellChecker: false,
                autoDownloadFontAwesome:false,
                element:document.getElementById("$column")
            });
EOT;
        return parent::render();

    }
}